﻿@using 检查页面开放.Models
@{
    ViewBag.Title = "MethodLog";
    Layout = null;
    List<MethodLog> methodLogList = ViewBag.MethodLogList;
    var json = Newtonsoft.Json.JsonConvert.SerializeObject(methodLogList);
}
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/vue.js"></script>
<style>
    select {
        min-width: 100px;
    }

    table {
        border-collapse: collapse;
        border: 1px solid black;
    }

    th, td {
        border: 1px solid black;
    }
	.spanModel{
		font:bold;
        padding-left:20px;
	}
    body{
        font-size:14px; 
    }
</style>
<div id="MethodVue">
    <div>
        迭代名称： 
        <input id="LogNameText" />
        <button onclick="jiLu(this)">记录</button>
    </div>
    <div>
        对比：
        <select id="Compare1">
            <option v-for="c in Compares" :value="c.ID">
                {{ c.Name }}
            </option>
        </select>
        <select id="Compare2">
            <option v-for="c in Compares" :value="c.ID">
                {{ c.Name }}
            </option>
        </select>
        <button onclick="compare(this)">对比</button>
        <div>
            <span>结果：</span>
            <div v-for="md in ModelDiffs">
                <div>
                    <span style="cursor:pointer;" onclick="modelDisplay(this)">折叠/展开</span> <span class='spanModel'>模块:{{md.Model.Name}}</span>
					<div style="display:none;">
                    <table>
                        <thead><tr> <th>C1:类.方法</th> <th>C2:类.方法</th><th>备注</th></tr></thead>
                        <tbody>
                            <tr v-for="d in md.MethodDiffs">
                                <td>{{d.Method1.ClassName}}.{{d.Method1.MethodName}}</td>
                                <td>{{d.Method2.ClassName}}.{{d.Method2.MethodName}}</td>
                                <td v-if="d.DiffType==1">删除</td>
                                <td v-if="d.DiffType==2">参数调整</td>
								<td v-if="d.DiffType==4">注释调整</td>
                                <td v-if="d.DiffType==5">新增</td>
                            </tr>
                        </tbody>
                    </table>
					</div>
                </div>
            </div>
            
        </div>
    </div>
</div>

<script>
    var compares = eval(@Html.Raw(json));
   var vueData= new Vue({
        el: '#MethodVue',
        data: {
            Compares: compares,
            ModelDiffs:[]
        }
    });

    function jiLu(obj) {
        $.ajax({
            url: "@Url.Content("JiLu")",
            data: "logName=" + $("#LogNameText").val(),
            success: function () {
                alert("记录成功！");
            },
            error: function (a, b, c) {
                alert(a.responseText);
            }
        }).always(function(a,b,c){
		 
		});
    }

    function compare() {
        var c1 = $("#Compare1").val();
        var c2=$("#Compare2").val();

        $.ajax({
            url: "@Url.Content("Compare")",
            data: "oldLog=" + c1 + "&newLog=" + c2,
            dataType:"json",
            success: function (re) {
                vueData.ModelDiffs = re;
            },
            error: function (a, b, c) {
                alert(a.responseText);
            }
        });
    }

	function modelDisplay(obj){
		var $this=$(obj);
		$this.nextAll("div").toggle();
	}
</script>